/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dictionary.dal;

import java.sql.Connection;
import java.sql.DriverManager;
import java.util.ResourceBundle;

/**
 *
 * @author s0c0labd
 */
public class ConnectDB {

    private Connection cn;

    public static Connection getConnection() {
        ResourceBundle bundle = ResourceBundle.getBundle("dictionary.bl.config");
        Connection cn = null;
        String driver = bundle.getString("driver");
        String protocol = bundle.getString("protocol");
        String server = bundle.getString("server");
        String port = bundle.getString("port");
        String dbName = bundle.getString("databaseName");
        String login = bundle.getString("login");
        String password = bundle.getString("password");
        StringBuilder sbURL = new StringBuilder(protocol);
        sbURL.append(server).append(":").append(port).append(";databaseName=").append(dbName);
        sbURL.append(";user=").append(login).append(";password=").append(password);
        String url = sbURL.toString();
        try {
            Class.forName(driver);
            cn = DriverManager.getConnection(url);
        } catch (Exception e) {
        }
        return cn;
    }
}
